import {Entity, Column, ManyToOne, Index} from "typeorm";
import {CommonEntity} from "~/common/entity/common.entity";
import {BookEntity} from "~/modules/books/book.entity";

@Index(["id"])
@Entity({name: "books_catalog"})
export class CatalogEntity extends CommonEntity{

  @Column({type: "int", comment: "目录排序"})
  order: number;

  @Column({type: "varchar", length: 50,  comment: "目录名称"})
  name: string;

  @Column({ type: "text", comment: "文本内容" })
  content: string;

  @ManyToOne(() => BookEntity, book => book.catalogs)
  book: BookEntity;
}
